package com.example.parkingproject.controller;

import com.example.parkingproject.jopo.entity.ParkingSpace;
import com.example.parkingproject.jopo.vo.ParkingSpaceListVo;
import com.example.parkingproject.result.JsonResult;
import com.example.parkingproject.service.ParkingSpaceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RequestMapping("/ParkingSpace")
@RestController
public class ParkingSpaceController {
    @Autowired
    ParkingSpaceService parkingSpaceService;

    @RequestMapping("/ParkingSpaceListOne")
    public JsonResult<List<ParkingSpaceListVo>> ParkingSpaceList() {
        List<ParkingSpaceListVo> list = parkingSpaceService.ParkingSpaceListOne();
        log.debug("查询出的参数{}", list);
        return JsonResult.ok(list);
    }

    @RequestMapping("/getRemainderOne")
    public JsonResult<Integer> getRemainder() {
        Integer remainder = parkingSpaceService.getRemainderOne();
        log.debug("查询出参数{}", remainder);
        return JsonResult.ok(remainder);
    }

    @RequestMapping("/ParkingSpaceListTow")
    public JsonResult<List<ParkingSpaceListVo>> ParkingSpaceListTow() {
        List<ParkingSpaceListVo> list = parkingSpaceService.ParkingSpaceListTow();
        return JsonResult.ok(list);
    }

    @RequestMapping("/getRemainderTow")
    public JsonResult<Integer> getRemainderTow() {
        Integer remainder = parkingSpaceService.getRemainderTow();
        return JsonResult.ok(remainder);
    }

    @RequestMapping("/ParkingSpaceListThree")
    public JsonResult<List<ParkingSpaceListVo>> ParkingSpaceListThree() {
        List<ParkingSpaceListVo> list = parkingSpaceService.ParkingSpaceListThree();
        return JsonResult.ok(list);
    }

    @RequestMapping("/getRemainderThree")
    public JsonResult<Integer> getRemainderThree() {
        Integer remainder = parkingSpaceService.getRemainderThree();
        return JsonResult.ok(remainder);
    }

    @RequestMapping("/getFreeSpaceList")
    public JsonResult<List<ParkingSpaceListVo>> ParkingSpace() {
        List<ParkingSpaceListVo> list = parkingSpaceService.ParkingSpace();
        return JsonResult.ok(list);
    }

    @RequestMapping("/getParkingSpace")
    public JsonResult<ParkingSpaceListVo> getParkingSpace(String locationNumber) {
        log.debug("传入参数{}",locationNumber);
        ParkingSpaceListVo parkingSpace = parkingSpaceService.getParkingSpace(locationNumber);
        log.debug("返回结果{}",parkingSpace);
        return JsonResult.ok(parkingSpace);
    }
}
